<template>
  <div>
    <div class="shop_item">
      <div class="allBox" v-for="(item,index) in shopInfo" :key="index">
        <div class="item_head">
          <van-icon name="shop-o" />
          <span> {{item.storeName}} </span>
          <van-icon name="arrow" />
        </div>
        <div class="item_body">
          <div class="input" @click="changeBol(item.id),getTotal(item.id)">
            <input type="checkbox" v-model="item.bol"   />
          </div>
          <div class="imgbox">
            <img src="./images/electric-04.jpg" alt="" />
          </div>
          <div class="textbox">
            <p class="textbox_title">{{item.intro}}</p>
            <p class="textbox_type">{{item.type}}</p>
            <p class="price">￥{{item.Newprice}} <span class="oldPrice">￥{{item.Oldprice}}</span></p>
            <div class="change">
              <span @click="changeNum(['-',item.id]),getTotal(item.id)">-</span>
              <span>{{item.num}}</span>
              <span @click="changeNum(['+',item.id]),getTotal(item.id)">+</span>
            </div>
          </div>
        </div>
        <p class="post">已享包邮</p>
      </div>
    </div>
  </div>
</template>

<script>
import  {mapMutations,mapState} from 'vuex'
export default {
  data() {
    return {
      shopInfo: this.$store.state.shopInfo,
      bol:true,
      total:0
    };
  },
  computed:{
    ...mapState(["ShopTotal"])
  },
  methods: {
      ...mapMutations(["changeNum","changeBol","getTotal"]),
  },
  mounted() {
    this.getTotal()
  },
};
</script>

<style scoped lang="less">
.shop_item {
  padding: 0.5rem 0.5rem;
}
.item_head {
  display: flex;
  padding: 0.1rem 0;
  position: relative;
  border-bottom: 1px solid rgb(233, 227, 227);
  .van-icon {
    margin-right: 0.1rem;
    font-size: 0.35rem;
  }
  .input,
  span {
    margin-right: 0.2rem;
  }
  .input {
    position: absolute;
    left: -0.5rem;
    top: 0.1rem;
    width: .4rem;
    height: .4rem;
    overflow: hidden;
    input{
      position: absolute;
      top: 0;
      left:0;
      z-index: -1;
    }
  }
}
.item_body {
  position: relative;
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  .oldPrice {
    text-decoration: line-through;
    color: gray;
  }
  .input {
    position: absolute;
    width: .4rem;
    height: .4rem;
    left: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    overflow: hidden;
    border-radius: 50%;
    input{
      position: absolute;
      top: 0;
      left:0;
      z-index: -1;
    }
  }
  .imgbox {
    height: 2.5rem;
    width: 2.5rem;
    img {
      width: 100%;
    }
  }
  .textbox {
    width: 4rem;
    margin-left: 0.2rem;
    position: relative;
    p {
      font-size: 0.1rem;
    }
    .price {
      position: absolute;
      bottom: 0.1rem;
      left: 0.1rem;
    }
    .change {
      position: absolute;
      bottom: 0.3rem;
      right: 0.1rem;
      span {
        display: inline-block;
        padding: 0.1rem;
        border: 1px solid rgb(209, 202, 202);
      }
    }
  }
}
.allBox{
    border-bottom: 1px solid rgb(223, 214, 214);
    margin-bottom: .2rem;
}
</style>